package com.gao.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Projectname SSM
 * @Filename controller
 * @Author an
 * @Data 2022/8/3 18:51
 * @Description TODO
 */

@Controller
@RequestMapping("/demo")
public class RequestMappingController {



    /*
    * @RequestMapping标识一个类：设置映射请求的请求路径的初始信息
      @RequestMapping标识一个方法：设置映射请求请求路径的具体信息
    * */

    //此时控制器方法所匹配的请求路径为/demo/hello
    @RequestMapping(value = {"/hello","/abc"},method = {RequestMethod.POST,RequestMethod.GET})
    public String hello(){
        return "success";
    }

    @RequestMapping("/a?a/test/ant")
    public String testAnt(){

        return "success";
    }

    @RequestMapping("/test/rest/{username}/{id}")
    public String testRest(@PathVariable("id") Integer id,@PathVariable("username") String username){

        System.out.println("id:"+id);
        System.out.println("username:"+username);
        return "success";
    }

}
